{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  {include file="headerPrint.tpl"}
{/if}
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
	{if $doSubmit == 1}
    bookFunction();
  {/if}
});
function deleteRow(vepaariBookDetailId)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway.") && confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "vepaaribillDelete.php?vepaariBookDetailId="+vepaariBookDetailId;
  }
}
function bookFunction(id)
{
  document.form1.bdate.value="1";
  document.form1.submit();
  form1.submitit.disabled=true;
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><h4>VepaariBook Detail</h4></center>
<div class="contentDiv">
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="0">
  {* Header Part Start*}
    <tr>
      <td class="table1">
        &nbsp;&nbsp;Party  : 
        <select name="party" onchange="bookFunction()">
          {html_options values=$party.partyId	 output=$party.partyName selected=$partyId}
        </select>
      </td>
      <td colspan="9" class="table1" nowrap>
      {if $doSubmit == 1}
        From :
        {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$fromDateSelected}}
        To: 
        {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$toDate}}   
        <input type="submit" name="submitBtn" value="Find" />
        {if $smarty.get.print != 1}
          <a href="vepaariBookListNew.php?print=1">Print</a>
        {else}
          &nbsp;
        {/if}
      {/if}
      </td>
    </tr>
  {* Header Part End *}
    <tr><hr/></tr>
    <tr class="table1" align="center">
      <th align="center" colspan="7">Aavak</th>
    </tr>
    <tr>
{* Aavak Section Start *}
    <table border="1" align="center" width="80%" cellspacing="1" cellpadding="1">
      <tr class="table1">  
        {if $smarty.get.print != 1}
          <td>&nbsp;</td>
        {else}
          &nbsp;
        {/if}
        <td align="center" style="border-right:1px solid;">Date</td>
        <td align="center" style="border-right:1px solid;">Parti</td>
        <td align="center" style="border-right:1px solid;">N.Wght</td>
        <td align="center" style="border-right:1px solid;">Touch</td>
        <td align="center" style="border-right:1px solid;">Fine</td>
        <td align="center" style="border-right:1px solid;">Amt</td>
      </tr>
      <tr class="table1">
        <td>&nbsp;</td> 
    	  <td align="center">Opening</td>
      	<td>&nbsp;</td>
     	  <td>&nbsp;</td>
        <td align="right">{if $openingFinalFineCr != 0}{$openingFinalFineCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right">{if $openingFinalAmountCr != 0}{$openingFinalAmountCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      <tr><hr/></tr>
      {section name="sec" loop=$billDetailCreditArray|@count}
        {if $smarty.section.sec.index != 0 && $billDetailCreditArray[sec].vepaariBookMasterId != $billDetailCreditArray[sec-1].vepaariBookMasterId}
         {* <tr class="table2"><td colspan="10"><hr/></td></tr> *}
        {/if}
        <td align="right" style="border-right:1px solid;" width="100" NOWRAP>{$billDetailCreditArray[sec].vepaariBookDate|date_format:"%d-%m-%Y"}</td>
        <td align="right" style="border-right:1px solid;">{$billDetailCreditArray[sec].particulars}</td>
        <td align="right" style="border-right:1px solid;">{if $billDetailCreditArray[sec].netWeight != 0}{$billDetailCreditArray[sec].netWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px solid;">{if $billDetailCreditArray[sec].touch != 0}{$billDetailCreditArray[sec].touch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px solid;">{if $billDetailCreditArray[sec].fine != 0}{$billDetailCreditArray[sec].fine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px solid;">{if $billDetailCreditArray[sec].amount != 0}{$billDetailCreditArray[sec].amount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {/section}
      <tr>
        <td colspan="10"><hr/></td>
      </tr>
      <tr class="table1">
        <td>&nbsp;</td>
        <td align="right">Total :&nbsp;&nbsp;&nbsp;</td>
        {if $smarty.get.print != 1}
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          {else}
        {/if} 
        <td align="right">&nbsp;</td>
        <td align="right">&nbsp;</td>
        <td align="right">{$total.CrFine|string_format:"%.0f"}</td>
        <td align="right">{$total.CrAmount|string_format:"%.0f"}</td>
      </tr>
    </table>
    <table>
      <tr align="left"><td><b>{if $vepaariCreditPrevFine >= 0} Total Debit Fine:{else} Total Credit Fine:{/if}{$vepaariCreditPrevFine|string_format:"%.0f"}</b></td></tr>
      <tr align="left"><td><b>{if $vepaariCreditPrevAmount >= 0} Total Debit Amount:{else} Total Credit Amount:{/if} {$vepaariCreditPrevAmount|string_format:"%.0f"}</b></td></tr>
      <tr><hr/></tr>
    </table>
  {* Jaavak Section End *}
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}
